package com.ziyia.property;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        ValueAnimator valueAnimator = ValueAnimator.ofFloat(0f, 100f);
        valueAnimator.setDuration(2000);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                Log.d("ofFloat", "value = " + value);
            }
        });
//        valueAnimator.start();


        ProgressBar progressBar = findViewById(R.id.progress_circular);
        ValueAnimator valueAnimator1 = ValueAnimator.ofInt(progressBar.getMax());
        valueAnimator1.setDuration(5000);
        valueAnimator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int value = (int) animation.getAnimatedValue();
                progressBar.setProgress(value);
                Log.d("ofInt", String.valueOf(value));
            }
        });
//        valueAnimator1.start();

        ValueAnimator valueAnimator2 = ValueAnimator.ofArgb(255, 255, 255, 0);
        valueAnimator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                Object animatedValue = animation.getAnimatedValue();
                Log.d("rgb", animatedValue.toString());
            }
        });
//        valueAnimator2.start();


        TextView textView = findViewById(R.id.text1);
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(textView,"alpha",0f, 1f);
        objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                Log.d("tab", animation.getAnimatedValue().toString());
            }
        });
        objectAnimator.setDuration(5000);
        objectAnimator.start();






    }
}